from random import randint

l = [randint(1, 100) for x in range(20)]
print l

def q_sort(l, left, right):
    if left > right:
        return
    i = left
    j = right
    flag = l[i]
    
    while i < j:
        while i < j and flag <= l[j]: 
            j = j - 1
        l[i] = l[j]
        while i < j and flag >= l[i]:
            i = i + 1
        l[j] = l[i]
    l[i] = flag
    q_sort(l, left, i - 1)
    q_sort(l, i + 1, right)
    return l

print q_sort(l, 0, len(l) - 1)
